#ifndef LIGHTMAP_H
#define LIGHTMAP_H

#include <QGraphicsItem>
#include <QRadialGradient>
#include <QPainter>

class LightMap : public QGraphicsItem
{
public:
    LightMap(QImage *shadowMap, qreal x, qreal y, qreal mSize)
    {
        qreal imageW = shadowMap->width();
        qreal imageH = shadowMap->height();

        QPainter painter;
        QRadialGradient gradient(QPointF(x+imageW/2, y+imageH/2), mSize/2, QPointF(x+imageW/2, y+imageH/2));
        //QRadialGradient gradient(QPointF(mX+1000, 100), 500/2, QPointF(100, 100));
        gradient.setColorAt(0, QColor(255, 255, 255, 0));
        gradient.setColorAt(1, QColor(255, 255, 255, 255));

        painter.begin(shadowMap);
        painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
        painter.setPen(Qt::NoPen);
        painter.setBrush(gradient);
        //painter->drawRect(mX+imageW, mY+imageH, mSize, mSize);
        painter.drawRect(x+imageW/2-mSize/2, y+imageH/2-mSize/2, mSize, mSize);
        painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
        painter.end();
    }

    //void drawLightMap

    QRectF boundingRect() const
    {
        return QRectF(-10, -10, 20, 20);
    }
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
               QWidget *widget)
    {
    }
};

#endif // LIGHTMAP_H
